import java.util.Arrays;
import java.util.Random;

public class Test {

    public static void inorderArray(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
        }
    }

    public static void notInorderArray(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = array.length-i;
        }
    }

    public static void initArray(int[] array) {
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(100000000);
        }
    }
    //开始测试 一些排序
    public static void testInsertSort(int[] array) {
        int[] tmpArray = Arrays.copyOf(array,2*array.length);
        long startTime = System.currentTimeMillis();
        Sort.insertSort(tmpArray);
        long endTime = System.currentTimeMillis();
        System.out.println("插入排序："+(endTime-startTime));
    }

    public static void testShellSort(int[] array) {
        int[] tmpArray = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.shellSort(tmpArray);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序："+(endTime-startTime));
    }

    public static void testSelectSort(int[] array) {
        int[] tmpArray = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.selectSort(tmpArray);
        long endTime = System.currentTimeMillis();
        System.out.println("选择排序："+(endTime-startTime));
    }

    public static void testHeapSort(int[] array) {
        int[] tmpArray = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.heapSort(tmpArray);
        long endTime = System.currentTimeMillis();
        System.out.println("堆排序："+(endTime-startTime));
    }

    public static void testQuickSort(int[] array) {
        int[] tmpArray = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSort(tmpArray);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序："+(endTime-startTime));
    }
    public static void testMergeSort(int[] array) {
        int[] tmpArray = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.mergeSort(tmpArray);
        long endTime = System.currentTimeMillis();
        System.out.println("归并排序："+(endTime-startTime));
    }



    public static void main2(String[] args) {
        int[] array = new int[10_0000];
        inorderArray(array);
        //notInorderArray(array);
        //initArray(array);
        //testInsertSort(array);
        //testShellSort(array);
        //testSelectSort(array);
        testHeapSort(array);
        testQuickSort(array);
        testMergeSort(array);
    }

    public static void main(String[] args) {
        int[] array = {1,3,5,2,3,7,1,5,8,3,4,2,1};
        Sort.countSort(array);
        System.out.println(Arrays.toString(array));
    }
}